﻿import com.dinmax.factorium.*

class FactoriumControl
extends MovieClip {

	private var mcControl:MovieClip;
	
	function onLoad():Void {
		FactoriumApp.getApp().setControl(this);
		this.initControl();
		return;
	};
	
	public function controlIn():Void {
		if(this._currentframe == 1) this.play();
		return;
	};
	
	public function controlOut():Void {
		this.onEnterFrame = function():Void {
			if(this._currentframe == 1){
				delete this.onEnterFrame;
			} else {
				this.prevFrame();
			};
			return;
		};
		return;
	};

	private function initControl():Void {
		this.initControlButton(this.mcControl.exitButton);		
		this.initControlButton(this.mcControl.prevButton);
		this.initControlButton(this.mcControl.nextButton);
		return;
	};

	private function initControlButton(clip:MovieClip):Void {
		clip.onPress=function():Void{
			switch(this._name){
				case "exitButton":
				FactoriumApp.getApp().getContent().hideContent();
				break;

				case "prevButton":
				FactoriumApp.getApp().getContent().prevSlide();
				break;

				case "nextButton":
				FactoriumApp.getApp().getContent().nextSlide();
				break;
			};
			return;
		};
		clip.onRollOver = function():Void {
			this.gotoAndStop("onRollOver");
			this._parent.mcFactoriumButton.setEnabled(true);
			return;
		};

		clip.onRollOut = function():Void {
			this.gotoAndStop("enabled");
			this._parent.mcFactoriumButton.setEnabled(false);
			return;
		};
		return;
	};

	public function setEnabledButtons(isEnabled:Boolean):Void {
		this.mcControl.prevButton.enabled = isEnabled;
		isEnabled ? this.mcControl.prevButton._alpha = 100 : this.mcControl.prevButton._alpha = 80;
		this.mcControl.nextButton.enabled = isEnabled;
		isEnabled ? this.mcControl.nextButton._alpha = 100 : this.mcControl.nextButton._alpha = 80;
		return;
	}
	
}; // end class